package vn.edu.saigontech.ncms.web.program;

import vn.edu.saigontech.ncms.model.enumeration.Currency;
import vn.edu.saigontech.ncms.model.program.Level;
import vn.edu.saigontech.ncms.model.system.Money;
import vn.edu.saigontech.ncms.service.LevelService;
import vn.edu.saigontech.ncms.web.BaseAction;

@SuppressWarnings("serial")
public class LevelAction extends BaseAction {
	
	private Long id;
	private String name;
	private Integer weeks;
	private Integer hours;
	private Double minScore;
	private Double maxScore;
	private Double tuition;
	private boolean active;
	private String content;
	
	public String showEdit() {
		REQUEST().setAttribute("level", LevelService.INSTANCE.findById(this.id));
		return SUCCESS;
	}
	
	public String edit() {
		Level level = LevelService.INSTANCE.findById(this.id);
		level.setName(this.name);
		level.setWeeks(this.weeks);
		level.setHours(this.hours);
		level.setMinScore(this.minScore);
		level.setMaxScore(this.maxScore);
		level.setTuition(new Money(this.tuition, Currency.USD));
		level.setActive(this.active);
		level.setContent(this.content);
		level = LevelService.INSTANCE.persist(level);
		this.addLoggingDetail(BaseAction.EDIT, "logging.level.edit", level.getName());
		return SUCCESS;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getWeeks() {
		return weeks;
	}

	public void setWeeks(Integer weeks) {
		this.weeks = weeks;
	}

	public Integer getHours() {
		return hours;
	}

	public void setHours(Integer hours) {
		this.hours = hours;
	}

	public Double getMinScore() {
		return minScore;
	}

	public void setMinScore(Double minScore) {
		this.minScore = minScore;
	}

	public Double getMaxScore() {
		return maxScore;
	}

	public void setMaxScore(Double maxScore) {
		this.maxScore = maxScore;
	}

	public Double getTuition() {
		return tuition;
	}

	public void setTuition(Double tuition) {
		this.tuition = tuition;
	}

	public Boolean getActive() {
		return active;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
}
